using Microsoft.Extensions.DependencyInjection;

namespace YMJake.Flowable.ExternalWorker.Client.AspNetCore.Pipeline;

/// <summary>
/// Builder for configuring Flowable workers with pipeline support
/// </summary>
public interface IFlowableWorkerBuilder
{
    /// <summary>
    /// The service collection
    /// </summary>
    IServiceCollection Services { get; }

    /// <summary>
    /// The topic this worker handles
    /// </summary>
    string Topic { get; }

    /// <summary>
    /// Add a handler to this worker
    /// </summary>
    /// <typeparam name="THandler">The handler type</typeparam>
    /// <returns>The builder for chaining</returns>
    IFlowableWorkerBuilder AddHandler<THandler>() where THandler : class, IWorkerHandler;

    /// <summary>
    /// Configure the pipeline for this worker
    /// </summary>
    /// <param name="configure">Pipeline configuration action</param>
    /// <returns>The builder for chaining</returns>
    IFlowableWorkerBuilder ConfigurePipeline(Action<IWorkerPipeline> configure);

    /// <summary>
    /// Set the concurrency level for this worker
    /// </summary>
    /// <param name="concurrency">Number of concurrent workers</param>
    /// <returns>The builder for chaining</returns>
    IFlowableWorkerBuilder WithConcurrency(int concurrency);

    /// <summary>
    /// Set the polling interval for this worker
    /// </summary>
    /// <param name="interval">Polling interval</param>
    /// <returns>The builder for chaining</returns>
    IFlowableWorkerBuilder WithPollingInterval(TimeSpan interval);

    /// <summary>
    /// Set the lock duration for jobs acquired by this worker
    /// </summary>
    /// <param name="duration">Lock duration</param>
    /// <returns>The builder for chaining</returns>
    IFlowableWorkerBuilder WithLockDuration(TimeSpan duration);
}